package com.ynny.chapter05_02.controller;

import com.ynny.chapter05_02.entity.User;
import com.ynny.chapter05_02.service.impl.UserServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserServiceImpl userService;

    @GetMapping("/list/{id}")
    public List<User> list(@PathVariable("id") int id){

        return userService.getAllUsers(id);

    }

    @GetMapping("/edit")
    public void edit(User user){

        userService.editUser(user);

    }
}
